package com.zp.util;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
/**
 * package format date tool
 * 
 * @author chenlijun08@gmail.com
 * 
 * @version 1.0
 * 
 * @since 1.0
 * 
 * @date 2014/1/20
 */
public class DateFormatUtil {

   /**
    * format Date
    * 
    * @param date 
    * 
    * @return String  like 'yyyy-MM-dd HH:mm:ss'
    */
   public static String DateFormat(Date date) {
      SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
      return format.format(date);
   }

   /**
    * format the Date
    * 
    * @param date
    * 
    * @return String like 'yyyyMMddHHmmss'
    */
   public static String DateFormatToFile(Date date) {
      SimpleDateFormat format = new SimpleDateFormat("yyyyMMddHHmmss");
      return format.format(date);
   }

   /**
    * create the file name along with date code
    * 
    * @return String
    */
   public static String createFlieName() {
      Calendar calCurrent = Calendar.getInstance();
      int intDay = calCurrent.get(Calendar.DATE);
      int intMonth = calCurrent.get(Calendar.MONTH) + 1;
      int intYear = calCurrent.get(Calendar.YEAR);
      int intHour = calCurrent.get(Calendar.HOUR);
      int intMinute = calCurrent.get(Calendar.MINUTE);
      int intSecond = calCurrent.get(Calendar.SECOND);
      StringBuilder builder = new StringBuilder();
      return builder.append(String.valueOf(intYear)).append(String.valueOf(intMonth)).append(String.valueOf(intDay))
            .append(String.valueOf(intHour)).append(String.valueOf(intMinute)).append(String.valueOf(intSecond))
            .append(".amr").toString();

   }

}
